/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package im.imrobots.v.live;

import im.imrobots._comn.ASession;
import im.imrobots._face.IContact;
import im.imrobots._face.IMessage;
import im.imrobots._face.IMimeMessage;
import java.io.File;
import net.sf.jml.MsnMessenger;
import net.sf.jml.MsnSwitchboard;
import net.sf.jml.message.MsnControlMessage;
import net.sf.jml.message.MsnInstantMessage;

/**
 *
 * @author yihaodian
 */
public class Session extends ASession
{
    MsnMessenger messenger;
    MsnSwitchboard switchboard;
    Contact contact = new Contact();
    MsnControlMessage writing;

    @Override
    public void send()
    {
        if (writing == null)
        {
            writing = new MsnControlMessage();
        }
        switchboard.sendMessage(writing);
    }

    @Override
    public void send(String text)
    {
        switchboard.sendText(text);
    }

    @Override
    public void send(IMessage message)
    {
        if (message instanceof Message)
        {
            switchboard.sendMessage(((Message) message).message);
        }
    }

    @Override
    public void send(IMimeMessage message)
    {
    }

    @Override
    public void send(File file)
    {
        switchboard.sendFile(file);
    }

    @Override
    public IContact getContact()
    {
        return contact;
    }

    @Override
    public IMessage createMessage()
    {
        return new Message(new MsnInstantMessage());
    }

    @Override
    public IMimeMessage createMimeMessage()
    {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
